﻿using MediatR;
using S.Authorization.Common.Dto;
using S.Authorization.Domain.Model.Organization;
using S.Authorization.Infrastructure.Interface.Organization;
using S.Authorization.Read.API.Application.Command.OrganizationCommand;

namespace S.Authorization.Read.API.Application.CommandHandlers.OrganizationCommandHandler
{
    public class ColumnManagementShowCommandHandler : IRequestHandler<ColumnManagementShowCommand, List<SelectDto>>
    {
        private readonly IColumnManagementRepository column;
        public ColumnManagementShowCommandHandler(IColumnManagementRepository _column)
        {
            column = _column;
        }
        public async Task<List<SelectDto>> Handle(ColumnManagementShowCommand request, CancellationToken cancellationToken)
        {
            List<ColumnManagementModel> childList = column.GetAllAsync().Result;
            List<SelectDto> children = childList.Select(x => new SelectDto
            {
                value = x.BuildingManagementId,
                label = x.BuildingName,
            }).ToList();
            return children;
        }
    }
}
